package com.qf.zxq.code.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qf.group.common.base.result.ResponseResult;
import com.qf.zxq.code.common.qo.CommodityQo;
import com.qf.zxq.code.common.vo.CommodityVo;
import com.qf.zxq.code.service.CommodityService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/commodity")
public class CommodityController {

    @Resource
    private CommodityService commodityService;

    @PostMapping("/{page}/{size}")
    @ApiOperation("进行分页查询商品，同时根据条件进行查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "页数"),
            @ApiImplicitParam(name = "size", value = "尺寸"),
            @ApiImplicitParam(name = "commodityQo", value = "查询条件")
    })
    public ResponseResult<IPage<CommodityVo>> searchAll(@PathVariable @RequestParam(defaultValue = "1") Integer page,
                                                        @PathVariable @RequestParam(defaultValue = "3") Integer size,
                                                        @RequestBody CommodityQo commodityQo) {
        return ResponseResult.success(commodityService.searchAll(page, size, commodityQo));
    }
}
